<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue-2.4.0.js"></script>
    <style>
        .boll{
            width:15px;
            height: 15px;
            background-color: red;
            border-radius: 50%;
        }
    </style>
</head>
<body>
<div id="app">
    <input type="button" value="加入购物车"  @click="flag = !flag"/>
    <transition
    @before-enter="beforeEnter"
    @enter="enter"
    @after-enter="afterEnter">
        <div class="boll" v-show="flag"></div>
    </transition>
</div>
<script>
    var vm = new Vue({
        el:'#app',
        data:{
            flag:false
        },
        methods:{
            //el============document.getElementById
            beforeEnter:function (el) {
                el.style.transform="translate(26px,-19px)"
            },
            enter:function (el,done) {
                //可以认为  el.offsetHeight 强制刷新动画
                el.offsetHeight;
                el.style.transform="translate(150px,450px)";
                el.style.transition="all 1s ease";
//                console.log(el.style.transform)

                //让小球到达位置立即消失      done()也可以理解为afterEnter的引用
                done()
            },
            afterEnter:function () {
                this.flag = !this.flag;

            }
        
    }
    });
</script>
</body>
</html>